#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

#define DEBUG 0
#define NOISY_TEST 1

int check_great_hall(int card, int choice1, int choice2, int choice3, struct gameState *post, int handPos, int bonus) {
  int i, currentPlayer;
  struct gameState pre;
  memcpy (&pre, post, sizeof(struct gameState));
  int r;
  r =  cardEffect(card, choice1, choice2, choice3, post, handPos, &bonus);
  currentPlayer = whoseTurn(&pre);
  drawCard(currentPlayer, &pre);
  pre.numActions++;
  discardCard(handPos, currentPlayer, &pre, 0);

  assert (r == 0);

  assert(memcmp(&pre, post, sizeof(struct gameState)) == 0);
  
  return 0;
}


int main () {

   int i, n, r, p, deckCount, discardCount, handCount, handPos;
   int card = great_hall;
   struct gameState G;
   int k[10] = {adventurer, council_room, feast, gardens, mine,
      	       remodel, smithy, village, baron, great_hall};
   printf ("Testing great_hall.\n");

   printf ("RANDOM TESTS.\n");

   SelectStream(2);
   PutSeed(3);

   for (n = 0; n < 2000; n++) {
      initializeGame(2, k, 3, &G);
      p = floor(Random() * 2);
      G.deckCount[p] = floor(Random() * MAX_DECK);
      G.discardCount[p] = floor(Random() * MAX_DECK);
      G.handCount[p] = floor(Random() * MAX_HAND);
      handPos = floor(Random() * G.handCount[p]);
      check_great_hall(card, -1, -1, -1, &G, handPos, 0);
   }

   printf ("ALL TESTS OK\n");



return 0;
}
